package com.cgc.shop.model;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * Category entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "category")
public class Category implements java.io.Serializable {

	// Fields

	private Integer id;
	private Account account;
	private String name;
	private Boolean popular;
	//private Set products = new HashSet(0);

	// Constructors

	/** default constructor */
	public Category() {
	}
	
	public Category(Integer id) {
		this.id = id;
	}

	/** full constructor */
	public Category(Account account, String name, Boolean popular, Set products) {
		this.account = account;
		this.name = name;
		this.popular = popular;
		//this.products = products;
	}
	
	public Category(Integer id, Account account, String name, Boolean popular, Set products) {
		this.id = id;
		this.account = account;
		this.name = name;
		this.popular = popular;
		//this.products = products;
	}

	// Property accessors

	@Override
	public String toString() {
		return "Category [id=" + id + ", account=" + account + ", name=" + name
				+ ", popular=" + popular + ", products=" + "]";
	}

	@Id
	@GeneratedValue
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "account_id")
	public Account getAccount() {
		return this.account;
	}

	public void setAccount(Account account) {
		this.account = account;
	}

	@Column(name = "name", length = 20)
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "popular")
	public Boolean getPopular() {
		return this.popular;
	}

	public void setPopular(Boolean popular) {
		this.popular = popular;
	}

	/*@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "category")
	public Set getProducts() {
		return this.products;
	}

	public void setProducts(Set products) {
		this.products = products;
	}*/

}